// 选择排序
function SelectionSort(nums) {
    for (var i = 0; i < nums.length(); i = i + 1) {
        for (var j = i + 1; j < nums.length(); j = j + 1) {
            if (nums[j] < nums[i]) {
                var t = nums[i]
                nums[i] = nums[j]
                nums[j] = t
            }
        }
    }
}

var nums = [3, 2, 1, 5, 4, 6, 9, 7, 8]
SelectionSort(nums)

for (var i = 0; i < nums.length(); ++i) {
    print(nums[i] + ' ')
}
